<template>
  <div class="app-container">
    <!-- 顶部导航栏 -->
    <div class="header-container">
      <!-- 左上角操作按钮 -->
      <div class="left-actions">
        <el-button 
          class="action-button" 
          @click="handleActionClick('广场')" 
          circle 
          title="广场"
          :type="$route.path === '/square' ? 'primary' : ''"
        >
          <Menu />
        </el-button>
        <el-button 
          class="action-button" 
          type="primary" 
          @click="handleActionClick('新增')" 
          circle 
          title="新增"
          :type="$route.path === '/create' ? 'primary' : ''"
        >
          <Plus />
        </el-button>
        <el-button 
          class="action-button" 
          @click="handleActionClick('查看收藏')" 
          circle 
          title="查看收藏"
          :type="$route.path === '/favorites' ? 'primary' : ''"
        >
          <CollectionTag />
        </el-button>
        <el-button 
          class="action-button" 
          @click="handleActionClick('反馈')" 
          circle 
          title="反馈"
        >
          <ChatDotRound />
        </el-button>
      </div>
      
      <!-- 右上角用户信息 -->
      <div class="user-info">
        <el-avatar size="medium" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" class="user-avatar"></el-avatar>
        <div class="user-details">
          <div class="user-name">AI助手</div>
          <div class="user-level">高级会员</div>
        </div>
        <el-dropdown>
          <el-button class="user-menu-button">
            <ArrowDown />
          </el-button>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>
                <template #icon>
                  <Setting />
                </template>
                设置
              </el-dropdown-item>
              <el-dropdown-item>
                <template #icon>
                  <Tools />
                </template>
                帮助
              </el-dropdown-item>
              <el-dropdown-item>
                <template #icon>
                  <SwitchButton />
                </template>
                退出登录
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>

    <!-- 路由视图 -->
    <router-view />
  </div>
</template>

<script>
import { ref } from 'vue'
import { 
  Menu, Plus, CollectionTag, ChatDotRound, ArrowDown, 
  Setting, Tools, SwitchButton 
} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

export default {
  name: 'App',
  setup() {
    const router = useRouter()
    
    // 用户信息
    const userInfo = ref({
      name: 'AI助手',
      level: '高级会员',
      avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
    })
    
    // 处理操作按钮点击事件
    const handleActionClick = (action) => {
      console.log(`执行操作: ${action}`)
      
      // 根据操作类型跳转到不同页面
      switch (action) {
        case '广场':
          router.push('/square')
          break
        case '新增':
          router.push('/create')
          break
        case '查看收藏':
          router.push('/favorites')
          break
        case '反馈':
          // 反馈功能可以是一个弹窗或其他交互
          alert('反馈功能即将上线，敬请期待！')
          break
        default:
          // 默认跳转到首页
          router.push('/')
      }
    }
    
    return {
      userInfo,
      handleActionClick
    }
  }
}
</script>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
}

/* 应用容器 */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  min-height: 100vh;
}

/* 顶部导航栏 */
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ebeef5;
}

/* 左上角操作按钮 */
.left-actions {
  display: flex;
  gap: 10px;
}

.action-button {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  transition: all 0.3s;
  font-size: 16px;
}

.action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 右上角用户信息 */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  border: 2px solid #409eff;
  transition: all 0.3s;
  cursor: pointer;
}

.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}

.user-details {
  text-align: right;
}

.user-name {
  font-weight: 600;
  color: #303133;
  margin-bottom: 2px;
}

.user-level {
  font-size: 12px;
  color: #409eff;
}

.user-menu-button {
  background-color: transparent;
  border: none;
  color: #909399;
}

.user-menu-button:hover {
  color: #409eff;
  background-color: #ecf5ff;
}

/* 搜索栏 */
.search-container {
  margin-bottom: 30px;
  text-align: center;
}

.search-input {
  width: 50%;
  max-width: 600px;
  height: 40px;
  border-radius: 20px;
  transition: all 0.3s;
}

.search-input:focus {
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

/* 主要内容区域 */
.main-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  position: relative;
}

/* 左右切换按钮 */
.nav-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  border: none;
  background-color: #f0f2f5;
}

.nav-button:hover:not(:disabled) {
  background-color: #409eff;
  color: white;
  transform: scale(1.1);
}

.nav-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

  /* 平台展示区域 */
  .platforms-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex: 1;
  }

/* 平台卡片 */
.platform-card {
  width: 300px;
  height: 400px;
  border-radius: 12px;
  background-color: #f8f9fa;
  border: 2px solid #e9ecef;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.platform-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  border-color: #409eff;
}

/* 提示词容器 */
.prompt-container {
  margin-bottom: 30px;
  text-align: center;
}

.prompt-textarea {
  width: 80%;
  max-width: 800px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.5;
  cursor: text; /* 确保显示文本光标 */
}

/* 平台图片占位 */
.platform-image {
  width: 100%;
  min-height: 250px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.platform-image::after {
  content: '生成效果';
  position: absolute;
  bottom: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: normal;
}

/* 平台名称 */
.platform-name {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
  margin-top: 10px;
}

/* 交互功能区域 */
.interaction-area {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

/* 交互按钮 */
.interaction-button {
  padding: 10px 24px;
  border-radius: 20px;
  transition: all 0.3s;
  font-size: 16px;
}

.interaction-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 运行按钮样式 */
.run-button {
  background-color: #67c23a;
  border-color: #67c23a;
}

.run-button:hover {
  background-color: #85ce61;
  border-color: #85ce61;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(103, 194, 58, 0.3);
}

.interaction-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 评论区域 */
.comments-area {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #ebeef5;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 评论区头部 */
.comments-header {
  margin-bottom: 20px;
}

.comments-header h3 {
  margin-bottom: 15px;
  color: #303133;
}

.comment-input {
  margin-bottom: 10px;
}

/* 评论列表 */
.comments-list {
  max-height: 400px;
  overflow-y: auto;
}

/* 评论项 */
.comment-item {
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 15px;
  transition: all 0.3s;
}

.comment-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comment-author {
  font-weight: 500;
  color: #409eff;
  margin-bottom: 5px;
}

.comment-content {
  margin-bottom: 8px;
  color: #606266;
  line-height: 1.5;
}

.comment-time {
  font-size: 12px;
  color: #909399;
}

/* 预览内容 */
.preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.preview-prompt {
  width: 100%;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f5f7fa;
  border-radius: 8px;
  border-left: 4px solid #409eff;
}

.preview-prompt-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #303133;
}

.preview-prompt-text {
  color: #606266;
  font-size: 16px;
  line-height: 1.5;
}

.preview-image {
  width: 100%;
  max-width: 600px;
  min-height: 300px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 48px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.preview-info {
  text-align: center;
}

.preview-info h3 {
  margin-bottom: 15px;
  color: #303133;
}

.preview-info p {
  margin-bottom: 10px;
  color: #606266;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
  }
  
  .left-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  
  .action-button {
    flex: 1;
    min-width: 40px;
    justify-content: center;
    margin-right: 5px;
    margin-bottom: 10px;
  }
  
  .user-info {
    width: 100%;
    justify-content: space-between;
  }
  
  .platforms-container {
    flex-direction: column;
    align-items: center;
  }
  
  .platform-card {
    width: 250px;
    min-height: 350px;
    height: auto;
  }
  
  .platform-image {
    width: 100%;
    min-height: 200px;
    font-size: 28px;
  }
  
  .platform-name {
    font-size: 20px;
  }
  
  .search-input {
    width: 80%;
  }
  
  .interaction-area {
    flex-wrap: wrap;
  }
  
  .preview-image {
    width: 100%;
    max-width: 300px;
    min-height: 200px;
    font-size: 32px;
  }
}
</style>